This sample shows how Windows Azure Mobile Services enables you to send email notifications.
This Windows Store app demonstrates a feedback charm that users can use to submit feedback about the app. After the user submits the feedback, it is sent to a Mobile Services table and is stored there for future analysis. After the feedback is received and stored, Mobile Services sends an email notification to a predetermined email account.
To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.
To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.
Note For Windows 8 app samples, download the Windows 8 app samples pack. The samples in the Windows 8 app samples pack will build and run only on Microsoft Visual Studio 2012.
Related topics
- free Windows Azure trial
- Send email from Mobile Services with SendGrid
- Windows Azure management portal
- Windows app samples
Operating system requirements
| Client | |
|---|---|
| Server |
Build the sample
- If you do not have a Windows Azure subscription, sign up for a free Windows Azure trial.
- Install the Windows Azure command line tools.
- Open a command prompt to download the required credentials to communicate with Windows Azure as follows. This is a one-time setup for running all subsequent commands to manage Mobile Services:
- Download Windows Azure management credentials with this command:
azure account download. This will display a web page for you to sign in to the Windows Azure management portal. After you sign in, Windows Azure will prompt you to download a publish settings file for your Windows Azure subscription. Save this file to your local computer. - Import the publish settings file from this location with this command:
azure account import[SavedLocation]. This will configure your command prompt to manage all of your Windows Azure services from the command line.
- Download Windows Azure management credentials with this command:
- Create a Windows Azure Mobile Service with this command:
azure mobile create[AzureMobileServiceName] [sqlAdminUsername] [sqlAdminPassword] - Create a
Feedbacktable to store all the feedback obtained from the app users, with this command:azure mobile table create[AzureMobileServiceName]Feedback - Go to Send email from Mobile Services with SendGrid and follow the instructions to create a
SendGridaccount. Make note of the account's user name and password. - Upload a script to your Windows Azure Mobile Service that will send the feedback in email as it is received from the user:
- From a command line, change to the sample's
Scriptsdirectory. - Open
feedback.insert.jsin theTablefolder and replace "{username}" with the SendGrid user name, "{password}" with the SendGrid password, and "{email-address}" with the email address that you want to email the received feedback to. - Run this command:
azure mobile script upload[AzureMobileServiceName]table/feedback.insert.js
- From a command line, change to the sample's
- Get the
ApplicationUrlandApplicationKeyfor your Windows Azure Mobile Service with this command:azure mobile show[AzureMobileServiceName] - Install the Windows Azure Mobile Services NuGet package.
- Open the
App.xaml.csfile and replace "mobile-service-url" and "mobile-service-key" with theApplicationUrlandApplicationKey. Your Windows Store app is now configured to communicate with your created Windows Azure Mobile Service. - Click Build > Build Solution.
Run the sample
- To debug the app and then run it in Microsoft Visual Studio, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
- After the app starts, move your mouse to the top right corner and then click
Feedback. Type some text and click Send Feeback. This sends the feedback to your Windows Azure Mobile Service and adds it as a row to the
Feedbacktable. It then send an email by usingSendGridand running the script that you uploaded. - You can also go to the Windows Azure management portal, sign in, and view your Windows Azure Mobile Service and the saved data.